// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import ElementUI from "element-ui";
import App from "./App";
import Vuex from "vuex";
// Jsonp
import { VueJsonp } from "vue-jsonp";
Vue.use(VueJsonp);

// IE 兼容
import "babel-polyfill";
import VueClipBoard from "vue-clipboard2";
import router from "@/router";
import Moment from "moment";
import "element-ui/lib/theme-chalk/index.css";
// 样式重置
import "@/assets/css/main.scss";
// 字体
import "font-awesome/css/font-awesome.css";

// 引入vuex状态管理数据
import store from "@/store";

// 引入Api，并挂载到vue上
// 组件内使用this.$apis.apiName调用
import Apis from "@/apis";

// 引入服务器配置，挂载到vue上
import address from "*/address.config";

// 引入公用方法，挂载到vue上
import utils from "@/utils";

// 引入导出表格方法，挂载到vue上
import table2excel from "@/utils/js-table2excel";

// 引入filters，并挂载到vue上
// 组件js代码和html属性上可以用this.$filters.filterName来调用
import filters from "@/filters";

// 以下代码为解决报错:vue-router.esm.js?fe87:2007 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}
import Router from "vue-router";
const routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error);
};

Vue.prototype.$apis = Apis;
Vue.prototype.$address = address;
Vue.prototype.$utils = utils;
Vue.prototype.$table2excel = table2excel;
Object.keys(filters).forEach(key => Vue.filter(key, filters[key]));
Vue.prototype.$filters = filters;
Vue.prototype.$moment = Moment;

Vue.config.productionTip = false;
Vue.use(VueClipBoard);
Vue.use(Vuex);
Vue.use(ElementUI);
/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  store,
  components: { App },
  template: "<App/>"
});
